#ifndef KM_H
#define KM_H
const static int K_cluster = 15;
class Kmeans {

private:
	ifstream loadfile;

	int* AmountLine;

	string index_nearest_center;

	bool is_stabled;

	vector<int> pointID;
	vector<int> pID;

	vector<int> sortedPoint;
	vector<int> startCenter;
	vector<string> cID;
	vector<string> sortedCenter;

	vector<int> prev_sortedPoint;
	vector<string> prev_sortedCenter;
	int text;
	vector<vector<double>> centers;

	map<string, vector<double>> cID_centers;

public:

	void AssertCondition(bool condition, const string error);
	vector<vector<double>> loadDataFromFile(char* filename);
	vector<int> SetPointID(vector<vector<double>> points);
	vector<vector<double>> SeedKmeansPPCenter(vector<vector<double>> points);
	double SetCutOff(double total_cost, int n, int centersize);
	double PointDistance(vector<double> center_point , vector<double>member_point);
	void selectedFirstCenter(int n,vector<int> &pID,vector<string> &cID, vector<vector<double>> points);
	double getNearestDistance(vector<vector<double>> centers, vector<double> point_i,  vector<string> cID,  int p, string &index_nearest_center);
	void assignPointsToClusters(vector<vector<double>> centers, vector<vector<double>> points);
	vector<vector<double>> UpdateCenterMean(vector<int> tmp_pID,vector<vector<double>> points, vector<vector<double>> centers);
	int FormCluster(vector<vector<double>> centers, vector<vector<double>> points);
	void SortMapCenter(map<int, string> m, vector<string> &prev_sortedCenter, vector<int> &prev_sortedPoint, vector<string> &sortedCenter, vector<int> &sortedPoint);
	vector<double> TotalNewMean(string currentCenter, vector<int> currentPointCluster, vector<vector<double>> points);
	map<string, vector<double>> Kmeans::MapCIDCenter(vector<string> &cID,vector<vector<double>> group_new_center);
	bool Kmeans::checkStatus();
	vector<vector<double>> SeedKmeansCenter(vector<vector<double>> points);
	void clearAllMemory();
	void writeValuesInputPhase3(string t,vector<string> &sortCID_return,vector<int> &sortPID_return, vector<int> &startCenter2);
};

#endif
